var cc__decorate = __decorate;
Object.defineProperty(exports, "__esModule", {
  value: true
});
var $2GameUser = require("GameUser");
var $2EventCenter = require("EventCenter");
var $2EventDefine = require("EventDefine");
var $2UIManager = require("UIManager");
var $2UIPtili = require("UIPtili");
var cc__decorator = cc._decorator;
var ccp_ccclass = cc__decorator.ccclass;
var ccp_property = cc__decorator.property;
var def_TiliView = /* */function (_cc$Component25) {
  function _ctor() {
    var _this89;
    babel_classCallCheck(this, _ctor);
    _this89 = _callSuper(this, _ctor, arguments);
    _this89.power = null;
    _this89.tiliBtn = null;
    _this89.loadingBar = null;
    _this89.curTili = 5;
    _this89.range = 0;
    _this89.deltaTime = 0;
    return _this89;
  }
  babel_inherits(_ctor, _cc$Component25);
  return babel_createClass(_ctor, [{
    key: "onLoad",
    value: function onLoad() {
      $2EventCenter.default.regisEvent($2EventDefine.default.GAME_TILI_INFO_UPDATE, this.syncGameTili, this);
    }
  }, {
    key: "onDestroy",
    value: function onDestroy() {
      $2EventCenter.default.removeEvent($2EventDefine.default.GAME_TILI_INFO_UPDATE, this.syncGameTili, this);
    }
  }, {
    key: "update",
    value: function update(e) {
      this.deltaTime += e;
      if (this.deltaTime > 1) {
        this.deltaTime = 0;
        if ($2GameUser.default.getInstance().tili < 5) {
          this.range += 1 / 600, this.range >= 1 && (this.range = 0, $2GameUser.default.getInstance().tili++, $2EventCenter.default.postEvent($2EventDefine.default.GAME_TILI_INFO_UPDATE)), this.loadingBar.fillRange = this.range;
        }
      }
    }
  }, {
    key: "showTiliView",
    value: function showTiliView() {
      this.node.opacity = 255;
    }
  }, {
    key: "hideTiliView",
    value: function hideTiliView() {
      this.node.opacity = 0;
    }
  }, {
    key: "syncGameTili",
    value: function syncGameTili() {
      this.curTili = $2GameUser.default.getInstance().tili;
      this.power.string = "".concat(this.curTili, "/5");
      cc.tween(this.tiliBtn).to(.1, {
        scale: 1.2
      }).to(.2, {
        scale: 1
      }).start();
    }
  }, {
    key: "onClickTili",
    value: function onClickTili() {
      $2UIManager.UIManager.getInstance().showUI($2UIPtili.default);
    }
  }]);
}(cc.Component);
cc__decorate([ccp_property(cc.Label)], def_TiliView.prototype, "power", undefined);
cc__decorate([ccp_property(cc.Node)], def_TiliView.prototype, "tiliBtn", undefined);
cc__decorate([ccp_property(cc.Sprite)], def_TiliView.prototype, "loadingBar", undefined);
def_TiliView = cc__decorate([ccp_ccclass], def_TiliView);
exports.default = def_TiliView;